package cn.xorange.commons.core.basic.bean;


import cn.xorange.commons.utils.configuration.constants.HttpStatus;

public enum SystemCode {

    SUCCESS(0, HttpStatus.SUCCESS,"请求成功"),

    FAIL(1,HttpStatus.SUCCESS,"请求失败"),

    //数据校验类
    DATABASE_RUN_EXCEPTION(1001, HttpStatus.ERROR,"数据库执行异常"),
    DATASOURCE_CHANGE_EXCEPTION(1002, HttpStatus.ERROR,"数据源切换异常"),
    DATASOURCE_NOTFOUND(1003,HttpStatus.ERROR,"没有找到对应数据源:"),
    DATABASE_LINK_FAILURE(1004,HttpStatus.ERROR,"数据库连接失败"),
    IBATIS_BINDING_ERROR(1005,HttpStatus.ERROR,"iBatis binding error"),

    SQL_ERROR(1101,HttpStatus.ERROR,"Sql语句出错"),
    SQL_DELETE_NO_WHERE(1102,HttpStatus.ERROR,"没有where不可删除全部数据"),
    SQL_UPDATE_NO_WHERE(1103,HttpStatus.ERROR,"没有where不可修改全部数据"),
    SQL_UPDATE_NO_VALUE_ERROR(1103,HttpStatus.ERROR,"没有更新字段，sql错误"),

    ENTITY_KEY_NOT_FOUND(1201,HttpStatus.ERROR,"没有设置主键列"),
    ENTITY_COL_NAME_ERROR(1202,HttpStatus.ERROR,"属性名匹配不到错误"),
    ENTITY_BATCH_ADD_ERROR(1203,HttpStatus.ERROR,"实体类批量新增异常"),
    ENTITY_UPDATE_OLD_VALUE_NULL(1204,HttpStatus.ERROR,"未找到需要更新的原数据"),
    ENTITY_NO_VERSION_PROPERTY(1205,HttpStatus.ERROR,"版本控制类没有updateTime属性"),


    DATA_UPDATE_NO_CHANGE(1301,HttpStatus.SUCCESS,"数据未改变"),
    DATA_VIOLATION_EXCEPTION(1302,HttpStatus.SUCCESS,"SQL参数不符合规范,不能进行处理"),
    DATA_UPDATE_VERSION_OLD(1303,HttpStatus.SUCCESS,"数据已被修改"),
    DATA_KEY_BUILD_FAIL(1304,HttpStatus.ERROR,"序列新增失败"),
    DATA_KEY_VALUE_NULL(1305,HttpStatus.ERROR,"主键值不能为空"),
    DATA_LENGTH_ERROR(1306,HttpStatus.ERROR,"字段长度限制错误"),
    DATA_NULL_ERROR(1307,HttpStatus.ERROR,"缺少必填参数"),
    DATA_INTEGRITY_CONSTRAINT_VIOLATION(1308,HttpStatus.ERROR,"插入数据库失败违反唯一约束"),
    DATA_REPEAT(1309,HttpStatus.ERROR,"已存在相同的"),
    DATA_REPEAT_ANNOTATION_ERROR(1310,HttpStatus.ERROR,"重复列未标明重复条件"),
    DATA_TREE_EXCEPTION(1311,HttpStatus.ERROR,"树类型数据错误"),



    //鉴权类
    PASSWORD_NULL(3101,HttpStatus.ERROR,"用户名密码不能为空"),
    PASSWORD_LENGTH_ERROR(3102,HttpStatus.ERROR,"密码长度不符合要求"),

    //User 认证
    TOKEN_GENERATE_ERROR(3201,HttpStatus.ERROR,"token生成失败"),
    TOKEN_NULL( 3202,HttpStatus.UNAUTHORIZED, "token为空"),
    TOKEN_KEY_NULL( 3203,HttpStatus.UNAUTHORIZED, "token key null"),
    TOKEN_UNAUTHORIZED(3204,HttpStatus.UNAUTHORIZED,"token未授权"),
    TOKEN_FORBIDDEN(3205,HttpStatus.UNAUTHORIZED, "token失效或已过期"),
    AUTH_USER_NOT_REGISTER(3206,HttpStatus.UNAUTHORIZED,"用户未注册"),

    AUTH_FAIL(3302,HttpStatus.FORBIDDEN,"当前操作没有权限"),
    AUTH_USERNAME_OR_PWD_ERROR(3305,HttpStatus.FORBIDDEN,"用户名密码错误"),
    AUTH_USER_LOCKED(3307,HttpStatus.FORBIDDEN,"账户被锁定"),
    AUTH_USER_DISABLE(3306,HttpStatus.FORBIDDEN,"用户被禁用，请联系管理员"),
    AUTH_USER_DELETED(3305,HttpStatus.FORBIDDEN,"用户已注销"),
    AUTH_USER_EXPIRATION(3308,HttpStatus.FORBIDDEN,"用户有效期到期"),

    AUTH_TENANT_NOT_FOUNT(3401,HttpStatus.SUCCESS,"渠道信息未找到"),
    AUTH_TENANT_DELETED(3402,HttpStatus.SUCCESS,"渠道账户被删除，请联系注册公司"),
    AUTH_TENANT_DISABLE(3403,HttpStatus.SUCCESS,"渠道账户被冻结，请联系注册公司"),
    AUTH_TENANT_EXPIRATION(3404,HttpStatus.SUCCESS,"渠道账户到期，请联系注册公司"),

    // Intercept
    INTERCEPT_RATE_LIMITER(4101,HttpStatus.ERROR,"访问过于频繁，请稍候再试"),
    INTERCEPT_RESUBMIT(4102,HttpStatus.ERROR,"不允许重复提交，请稍候再试"),

    // 文件处理类
    FILE_SIZE_LIMIT(4201,HttpStatus.SUCCESS,"文件大小超限"),
    FILE_NAME_LENGTH(4202,HttpStatus.SUCCESS,"FileNameLength"),
    FILE_UPLOAD_ERROR(4203,HttpStatus.ERROR,"FileUploadError"),
    FILE_UPLOAD_NULL(4204,HttpStatus.SUCCESS,"没有上传文件"),

    //业务处理类
    USERNAME_NO_MATCH(5001,HttpStatus.SUCCESS,"用户名不符合规范要求"),
    USED_NOT_DELETE(5101,HttpStatus.SUCCESS,"已使用，不可删除"),
    USER_LOGIN_TYPE_NULL(5201,HttpStatus.SUCCESS,"登录类型异常"),
    USER_PARAM_NULL(5301,HttpStatus.SUCCESS,"缺少参数"),


    //其他错误
    SYSTEM_EXCEPTION(9001,HttpStatus.ERROR,"系统繁忙，请稍候再试"),
    SYSTEM_UNKNOWN_EXCEPTION(9002,HttpStatus.ERROR,"未知错误"),
    SYSTEM_NULL_POINT_EXCEPTION(9003,HttpStatus.ERROR,"空指针异常"),
    SYSTEM_PRE_AUTH_EXCEPTION(9004,HttpStatus.ERROR,"配置错误,缺少权限"),
    SYSTEM_PARAM_EXCEPTION(9005,HttpStatus.ERROR,"系统缺少参数"),
    SYSTEM_PATH_NOT_FOUND(9006,HttpStatus.NOT_FOUND,"路径不存在，请检查路径是否正确"),
    SYSTEM_REQUEST_NULL(9007,HttpStatus.ERROR,"请求为空"),
    SYSTEM_RESPONSE_NULL(9008,HttpStatus.ERROR,"响应为空异常"),
    SYSTEM_TYPE_EXCEPTION(9010,HttpStatus.ERROR,"系统类型判定异常"),
    SYSTEM_CACHE_NULL(9020,HttpStatus.ERROR,"缓存中没有定义"),
    SYSTEM_CACHE_KEY_NULL(9021,HttpStatus.ERROR,"缓存查询的key不能为空"),
    SYSTEM_APPID_SECRET_EXCEPTION(9022, HttpStatus.ERROR, "appSecret获取失败");







    private int code;
    private int status;
    private String msg;
    SystemCode(int code, int httpCode, String msg){
        this.code = code;
        this.status = httpCode;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }
    public int getStatus(){ return status; }
    public String getMsg() {
        return msg;
    }

    public void setCode(Integer code){
        this.code = code;
    }
    public void setStatus(Integer status){
        this.status = status;
    }
    public void setMsg(String msg){
        this.msg = msg;
    }
}
